<!DOCTYPE html>
<html>
<head>
    <title>新品有戏后台管理</title>
    <link href="__CSS__/boot.css" rel="stylesheet">
    <link href="__STATIC__/layui/css/layui.css" rel="stylesheet">
    <script src="__JS__/jquery.js"></script>
    <script src="__JS__/layer/layer.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <style>
        tr td{
            text-align: center;
            vertical-align: middle!important;
        }
    </style>
</head>
<body>
{include file="base/header"}
<div style="height:1px;"></div>

<div style="float: right; margin-top: 5px;margin-bottom: 5px" class="box-title " >
    <form class="form-inline" action="{:url('online/index/index')}" method="get">
        <input type="text" name="title" value="<?php if(isset($title)) echo $title ?>" placeholder="联系人，联系电话" class="form-control" id="exampleInputEmail3" >
        <input type="submit" class="btn btn-default" value="搜索"/>
        <input type="button" onclick="res()" value="全部显示" class="btn btn-default"/>
    </form>
</div>
<table class="layui-table" id="test_table">
    <thead>
    <tr>
        <!--<td>请选择</td>-->
        <td>编号</td>
        <td>商家联系人</td>
        <td>联系电话</td>
        <td>操作</td>
    </tr>
    </thead>
    <tbody>
    {foreach $result as $val}
        <tr>
            <!--<td><input type="checkbox" name="check"/></td>-->
            <td>{$val.id}</td>
            <td>{$val.linkman}</td>
            <td>{$val.telephone}</td>
            <td>
                <button  onclick="goods({$val.id})" type="button" class="btn btn-primary btn-xs">查看商品</button>
            </td>
        </tr>
    {/foreach}
    </tbody>
</table>
{$result->render()}
</body>
<script>
    //全部显示
    function res() {
        window.location.href = "{:url('online/index/index')}";
    }
    //查看商品
    function goods(id) {
        window.location.href = "{:url('online/index/goods')}?bid="+id;
    }
    //添加购物车
    function add() {
        var box = $("input[name=check]:checked").val();
        if(!box){
            layer.alert('请选择需要邮寄的商品');
            return;
        }
        var single = [];
        var rows = document.getElementById("test_table").rows;
        var check = document.getElementsByName("check");
        var  table = document.getElementById("test_table");
        for(var i=0;i<check.length;i++)
        {
            if(check[i].checked){
                var row = check[i].parentElement.parentElement.rowIndex;
                single.push(rows[row].cells[1].innerHTML);
            }
        }
        $.ajax({
            url:"{:url('online/index/shopping')}",
            data:"data="+JSON.stringify(single),
            type:"post",
            dataType:"json",
            success:function (res) {
                if(res.success){
                    layer.alert(res.success);
                }
                if(res.error){
                    layer.alert(res.error);
                }
            }
        });
    }
</script>
</html>